#include <utility>
#include <vector>
#include <iostream>

using namespace std;

struct FeedInfo {
  int packs;
  int balance;
};

FeedInfo feedCows(vector<int> &h) {
  FeedInfo result {-1, -1};

  if (h.size() == 2 && h[0] == h[1]) {
    result = {0, h[0]};
  }
  else if (h.size() >= 3) {
    int i = 0;
    while (i + 2 < h.size()) {

    }

    if (h.size() % 3 == 1) {

    }
    else if (h.size() % 3 == 2) {
      
    }
  }

  return result;
}

FeedInfo feedTripleCows(vector<int> &h, int pos) {
  int fst = h[pos];
  int snd = h[pos + 1];
  int third = h[pos + 2];

  if (fst == snd && fst >= third) {
    return {
      (fst - third) * 2,
      third
    };
  }
  else if (snd == third && snd >= fst) {
    return {
      (snd - fst) * 2,
      fst
    };
  }
  else if (snd > fst && snd > third) {
    int result = 0;

    int d1 = snd - fst;
    int newThird = third - d1;
    result += (d1 * 2);

    int d3 = fst - newThird;
    result += (d3 * 2);

    return {
      result,
      newThird
    };
  }

  return { -1, -1 };
}

int main(int argc, char const *argv[])
{
  /* code */
  int n = 0;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    // We have n round tests.
    int cows = 0;
    cin >> cows;
    vector<int> h_degrees; // Hungry degrees
    
    for (int j = 0; j < cows; ++j) {
      int h = 0;
      cin >> h;
      h_degrees.push_back(h);
    }

    for (auto h : h_degrees) {
      cout << h << " ";
    }
    cout << endl;

    auto result = feedTripleCows(h_degrees, 0);

    cout << "Need " << result.packs << " packages." << endl;
    cout << "They are balanced at: " << result.balance << "." << endl;
  }

  return 0;
}
